﻿using System;
using System.Data;
using System.Web.UI;
using BLL;
using Utils;
namespace UI.ModEmployee
{
    public partial class EmpTotalMemberList : System.Web.UI.Page
    {
        DefDicBiz defDicBiz = new DefDicBiz();
        EmployeeBiz employeeBiz = new EmployeeBiz();
        string account = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] != null)
            {
                User user = Session["user"] as User;
                account = user.Account;
            }
            else
            {
                JSUtility.Alert(this, "您没有登录!请先登录。");
                return;
            }
            if (!Page.IsPostBack)
            {
                if (!AccountBiz.CheckRight(account, "EmpTotalMemberList.aspx", RightChar.Ser))
                {
                    JSUtility.Alert(this, "无权限！");
                    return;
                }
                DateTime dt = DateTime.Now;
                defDicBiz.InitDropDownList(ddlMonth, dt.Month.ToString());

                DataSet ds = employeeBiz.GetLimitList(dt.Year.ToString(), dt.AddMonths(-1).Month.ToString());
                gvList.Caption = "<b>" + dt.Year.ToString() + "年" + dt.AddMonths(-1).Month.ToString() + "月份总人数一览表</b>";
                gvList.DataSource = ds.Tables[0];
                gvList.DataBind();
            }

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            
          string thisMonth=  ddlMonth.SelectedValue;
          string thisYear = ddlYear.SelectedValue;
         
          DataSet ds = employeeBiz.GetLimitList(thisYear, thisMonth);
          gvList.Caption ="<b>"+ thisYear + "年" + thisMonth + "月份总人数一览表</b>";
          gvList.DataSource = ds.Tables[0];
          gvList.DataBind();
        }

        protected void btnExcel_Click(object sender, EventArgs e)
        {
            if (!AccountBiz.CheckRight(account, "EmpTotalMemberList.aspx", RightChar.Out))
            {
                JSUtility.Alert(this, "无权限！");
                return;
            }
            ExcelUtility.GridViewToExcel(gvList, "EmpTotalList.xls");
            //string thisMonth = ddlMonth.SelectedValue;
            //string thisYear = ddlYear.SelectedValue;
            //ExcelUtility.ExportSqlToExcel("exec sp_JimLimitStatu " + thisYear + "," + thisMonth, XmlUtility.GetConnFormConfig());
        }
    }
}